package com.qst.singer.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qst.domain.entity.Mess;
import com.qst.domain.entity.Music;
import com.qst.singer.service.MusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/singer")
public class SingerController {
    @Autowired
    MusicService musicService;

    @GetMapping("/pageMusic/{pn}/{size}")
    public Mess getPage(@PathVariable(value = "pn")Integer pn, @PathVariable(value = "size")Integer size, String keyword, @RequestHeader("id")Integer id){
        return musicService.getMusic(keyword,id,pn,size);
    }

    @PostMapping("/addMusic")
    public Mess addMusic(@RequestBody Music music, @RequestHeader("id")Integer id){
        return musicService.addMusic(music,id);
    }

    @PostMapping("/update")
    public Mess update(@RequestBody Music music,@RequestHeader("id")Integer id){
        return musicService.updateMusic(music,id);
    }

    @PostMapping("/delete")
    public Mess delete(Integer musicId ,@RequestHeader("id")Integer id){
        return musicService.deleteMusic(musicId,id);
    }

    @GetMapping("/getMess")
    public Mess getMess(@RequestHeader("id")Integer id){
        return musicService.getMessage(id);
    }
}
